<?php include template("manage_header");?>

<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="leader">
	<div class="dashboard" id="dashboard">
		<ul><?php echo mcurrent_team('team'); ?></ul>
	</div>
	<div id="content" class="clear mainwide">
        <div class="clear box">
            <div class="box-top"></div>
            <div class="box-content">
                <div class="head">
				<?php if($team['id']){?>
					<h2>Edit deals</h2>
					<ul class="filter"><?php echo current_manageteam('edit', $team['id']); ?></ul>
				<?php } else { ?>
					<h2>Creat deals</h2>
				<?php }?>
				</div>
                <div class="sect">
				<form id="-user-form" method="post" action="/manage/team/edit.php?id=<?php echo $team['id']; ?>" enctype="multipart/form-data" class="validator">
					<input type="hidden" name="id" value="<?php echo $team['id']; ?>" />
					<div class="wholetip clear"><h3>1 basic info</h3></div>
					<div class="field">
						<label>deal type</label>
						<select name="team_type" class="f-input" style="width:160px;" onchange="X.team.changetype(this.options[this.options.selectedIndex].value);"><?php echo Utility::Option($option_teamtype, $team['team_type']); ?></select><select name="city_id" class="f-input" style="width:160px;"><?php echo Utility::Option(Utility::OptionArray($allcities, 'id','name'), $team['city_id'], 'all cities'); ?></select>
						<select name="group_id" class="f-input" style="width:160px;"><?php echo Utility::Option($groups, $team['group_id']); ?></select>
					</div>
					<div class="field" id="field_limit">
						<label>limitations</label>
						<select name="conduser" class="f-input" style="width:160px;"><?php echo Utility::Option($option_cond, $team['conduser']); ?></select>
						<select name="buyonce" class="f-input" style="width:160px;"><?php echo Utility::Option($option_buyonce, $team['buyonce']); ?></select>
					</div>
					<div class="field">
						<label>deal title</label>
						<input type="text" size="30" name="title" id="team-create-title" class="f-input" value="<?php echo htmlspecialchars($team['title']); ?>" datatype="require" require="true" />
					</div>
					<div class="field">
						<label>market price</label>
						<input type="text" size="10" name="market_price" id="team-create-market-price" class="number" value="<?php echo moneyit($team['market_price']); ?>" datatype="money" require="true" />
						<label>web price</label>
						<input type="text" size="10" name="team_price" id="team-create-team-price" class="number" value="<?php echo moneyit($team['team_price']); ?>" datatype="double" require="true" />
						<label>virtual buyers</label>
						<input type="text" size="10" name="pre_number" id="team-create-pre_number" class="number" value="<?php echo moneyit($team['pre_number']); ?>" datatype="number" require="true" />
					</div>
					<div class="field">
						<label>lower limit</label>
						<input type="text" size="10" name="min_number" id="team-create-min-number" class="number" value="<?php echo intval($team['min_number']); ?>" maxLength="6" datatype="number" require="true" />
						<label>upper limit</label>
						<input type="text" size="10" name="max_number" id="team-create-max-number" class="number" value="<?php echo intval($team['max_number']); ?>" maxLength="6" datatype="number" require="true" />
						<label>limit for one user</label>
						<input type="text" size="10" name="per_number" id="team-create-per-number" class="number" value="<?php echo intval($team['per_number']); ?>" maxLength="6" datatype="number" require="true" />
						<span class="hint">The lower limit must be bigger than 0, the biggest quantity/every user's limit of buying：0 means no upper limit （quantity of goods|numbers of buyers which are determined by the conditions of a successful deal）</span>
					</div>
					<div class="field">
						<label>Start time</label>
						<input type="text" size="30" name="begin_time" id="" class="numberd" xd="<?php echo date('Y-m-d', $team['begin_time']); ?>" xt="<?php echo date('H:i:s', $team['begin_time']); ?>" value="<?php echo date('Y-m-d H:i:s', $team['begin_time']); ?>" maxlength="30" /></div>
<div class="field">
						<label>End time</label>
						<input type="text" size="30" name="end_time" id="" class="numberd" xd="<?php echo date('Y-m-d', $team['end_time']); ?>" xt="<?php echo date('H:i:s', $team['end_time']); ?>" value="<?php echo date('Y-m-d H:i:s', $team['end_time']); ?>" maxlength="30" /></div>
<div class="field">
						<label><?php echo $INI['system']['couponname']; ?> Due Time</label>
						<input type="text" size="30" name="expire_time" id="" class="numberd" value="<?php echo date('Y-m-d', $team['expire_time']); ?>" maxLength="30" />
						<span class="hint">Date/time format：YYYY-MM-DD HH:MM:SS （example：2010-06-10 23:12:09）</span>
					</div>
					<div class="field">
						<label>Introduction of this deal</label>
						<div style="float:left;"><textarea cols="45" rows="5" name="summary" id="team-create-summary" class="f-textarea editor2" datatype="require" require="true"><?php echo htmlspecialchars($team['summary']); ?></textarea></div>
					</div>
					<div class="field">
						<label>Tips</label>
						<div style="float:left;"><textarea cols="45" rows="5" name="notice" id="team-create-notice" class="f-textarea editor1" style="width:710px;height:150px;"><?php echo $team['notice']; ?></textarea></div>
						<span class="hint">due time and descriptions of this deal</span>
					</div>
					<!--kxx-->
					<div class="field">
						<label>sort</label>
						<input type="text" size="10" name="sort_order" id="team-create-sort_order" class="number" value="<?php echo $team['sort_order'] ? $team['sort_order'] : 0; ?>" datatype="number"/><span class="inputtip">Please fill out with figures which are ranked from big to small, and set a bigger one for the main deal</span>
					</div>
					<!--xxk-->
					<input type="hidden" name="guarantee" value="Y" />
					<input type="hidden" name="system" value="Y" />
					<div class="wholetip clear"><h3>2、deal info</h3></div>
					<div class="field">
						<label>Partner</label>
						<select name="partner_id" datatype="require" require="require" class="f-input" style="width:200px;"><?php echo Utility::Option($partners, $team['partner_id'], '--- please select a Partner ---'); ?></select><span class="inputtip">Partner is optional</span>
					</div>
					<div class="field" id="field_card">
						<label>card use</label>
						<input type="text" size="10" name="card" id="team-create-card" class="number" value="<?php echo moneyit($team['card']); ?>" require="true" datatype="money" />
						<span class="inputtip">The biggest card value can be used</span>
					</div>
					<div class="field" id="field_card">
						<label>invitation rebate</label>
						<input type="text" size="10" name="bonus" id="team-create-bonus" class="number" value="<?php echo moneyit($team['bonus']); ?>" require="true" datatype="money" />
						<span class="inputtip">the amount of rebate which you get from your invited friend's buying</span>
					</div>
					<div class="field">
						<label>goods name</label>
						<input type="text" size="30" name="product" id="team-create-product" class="f-input" value="<?php echo $team['product']; ?>" datatype="require" require="true" />
					</div>
					<div class="field">
						<label>essential options of buying</label>
						<input type="text" size="30" name="condbuy" id="team-create-condbuy" class="f-input" value="<?php echo $team['condbuy']; ?>" />
						<span class="hint">format is as：{yellow}{green}{red}，user must choose one of them when buying</span>
					</div>
					<div class="field">
						<label>goods pictures</label>
						<input type="file" size="30" name="upload_image" id="team-create-image" class="f-input" />
						<?php if($team['image']){?><span class="hint"><?php echo team_image($team['image']); ?></span><?php }?>
					</div>
					<div class="field">
						<label>goods picture 1</label>
						<input type="file" size="30" name="upload_image1" id="team-create-image1" class="f-input" />
						<?php if($team['image1']){?><span class="hint" id="team_image_1"><?php echo team_image($team['image1']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 1);">delete</a></span><?php }?>
					</div>
					<div class="field">
						<label>goods picture 2</label>
						<input type="file" size="30" name="upload_image2" id="team-create-image2" class="f-input" />
						<?php if($team['image2']){?><span class="hint" id="team_image_2"><?php echo team_image($team['image2']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 2);">delete</a></span><?php }?>
					</div>
					<!-- them hinh cho deal 4-5 -->
					<div class="field">
						<label>goods picture 3</label>
						<input type="file" size="30" name="upload_image3" id="team-create-image3" class="f-input" />
						<?php if($team['image3']){?><span class="hint" id="team_image_3"><?php echo team_image($team['image3']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 3);">delete</a></span><?php }?>
					</div>
					<div class="field">
						<label>goods picture 4</label>
						<input type="file" size="30" name="upload_image4" id="team-create-image4" class="f-input" />
						<?php if($team['image4']){?><span class="hint" id="team_image_4"><?php echo team_image($team['image4']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 4);">delete</a></span><?php }?>
					</div>										
					<!-- end -->
					<!-- bo xung hinh cua phieu voucher -->
					<div class="field">
						<label>Voucher image 1</label>
						<input type="file" size="30" name="voucher_1" id="voucher-create-image1" class="f-input" />
						<?php if($team['image5']){?><span class="hint" id="team_image_5"><?php echo team_image($team['image5']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 5);">delete</a></span><?php }?>
					</div>
					<div class="field">
						<label>Voucher image 2</label>
						<input type="file" size="30" name="voucher_2" id="voucher-create-image2" class="f-input" />
						<?php if($team['image6']){?><span class="hint" id="team_image_6"><?php echo team_image($team['image6']); ?>&nbsp;&nbsp;<a href="javascript:;" onclick="X.team.imageremove(<?php echo $team['id']; ?>, 6);">delete</a></span><?php }?>
					</div>										
					<!-- end -->					
					<div class="field">
						<label>FLV.sw</label>
						<input type="text" size="30" name="flv" id="team-create-flv" class="f-input" value="<?php echo $team['flv']; ?>" />
						<span class="hint">format is as：http://.../video.flv</span>
					</div>
					<div class="field">
						<label>detail</label>
						<div style="float:left; width: 80%;"><?php echo $detail; ?></div>
					</div>
					<div class="field" id="field_userreview">
						<label>User Reviews</label>
						<div style="float:left;"><textarea cols="45" rows="5" name="userreview" id="team-create-userreview" class="f-textarea editor1"><?php echo htmlspecialchars($team['userreview']); ?></textarea></div>
						<span class="hint">Format:“Good with | Rita|http://ww....|XXX Network”，Write a comment per line</span>
					</div>
					<div class="field">
						<label><?php echo $INI['system']['abbreviation']; ?> Says</label>
						<div style="float:left;width: 80%;"><?php echo $systemreview; ?></div>
					</div>
					<div class="wholetip clear"><h3>3, Distribution of information</h3></div>
					<div class="field">
						<label>Mode of delivery</label>
						<div style="margin-top:5px;" id="express-zone-div"><input type="radio" name="delivery" value="coupon" <?php echo $team['delivery']=='coupon'?'checked':''; ?> />&nbsp;<?php echo $INI['system']['couponname']; ?>&nbsp;<input type="radio" name="delivery" value='express' <?php echo $team['delivery']=='express'?'checked':''; ?> />&nbsp;Express delivery</div>
					</div>
					<div id="express-zone-coupon" style="display:<?php echo $team['delivery']=='coupon'?'block':'none'; ?>;">
						<div class="field">
							<label>Consumer rebates</label>
							<input type="text" size="10" name="credit" id="team-create-credit" class="number" value="<?php echo moneyit($team['credit']); ?>" datatype="money" require="true" />
							<span class="inputtip">Consumer<?php echo $INI['system']['couponname']; ?>Obtained when the account balance rebate, unit USD</span>
						</div>
					</div>
					<div id="express-zone-pickup" style="display:<?php echo $team['delivery']=='pickup'?'block':'none'; ?>;">
						<div class="field">
							<label>Contact</label>
							<input type="text" size="10" name="mobile" id="team-create-mobile" class="f-input" value="<?php echo $team['mobile']; ?>" />
						</div>
						<div class="field">
							<label>Self-created address</label>
							<input type="text" size="10" name="address" id="team-create-address" class="f-input" value="<?php echo $team['address']; ?>" />
						</div>
					</div>
					<div id="express-zone-express" style="display:<?php echo $team['delivery']=='express'?'block':'none'; ?>;">
						<div class="field">
							<label>Delivery costs</label>
							<input type="text" size="10" name="fare" id="team-create-fare" class="number" value="<?php echo intval($team['fare']); ?>" maxLength="6" datatype="money" require="true" />
							<label>Fare</label>
							<input type="text" size="10" name="farefree" id="team-create-farefree" class="number" value="<?php echo intval($team['farefree']); ?>" maxLength="6" datatype="money" require="true" />
							<span class="hint">Courier costs, free single number: 0 can not help but freight, 2 said the purchase of two free shipping</span>
						</div>
						<div class="field">
							<label>Delivery Help</label>
							<div style="float:left;width: 80%"><?php echo $express; ?></div>
						</div>
					</div>
					<input type="submit" value="Save" name="commit" id="leader-submit" class="formbutton" style="margin:10px 0 0 120px;"/>
				</form>
                </div>
            </div>
            <div class="box-bottom"></div>
        </div>
	</div>
<div id="sidebar">
</div>

</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->

<script type="text/javascript">
window.x_init_hook_teamchangetype = function(){
	X.team.changetype("<?php echo $team['team_type']; ?>");
};
window.x_init_hook_page = function() {
	X.team.imageremovecall = function(v) {
		jQuery('#team_image_'+v).remove();
	};
	X.team.imageremove = function(id, v) {
		return !X.get(WEB_ROOT + '/ajax/misc.php?action=imageremove&id='+id+'&v='+v);
	};
};
</script>
<?php include template("manage_footer");?>
